package com.hyacinth.lotterysystem.controller;

import com.hyacinth.lotterysystem.common.pojo.CommonResult;
import com.hyacinth.lotterysystem.dto.req.DrawPrizeReq;
import com.hyacinth.lotterysystem.dto.req.WinningRecordReq;
import com.hyacinth.lotterysystem.dto.resp.WinningRecordResp;
import com.hyacinth.lotterysystem.service.DrawPrizeService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DrawPrizeController {
    private static final Logger logger = LoggerFactory.getLogger(DrawPrizeController.class);

    @Resource
    private DrawPrizeService drawPrizeService;

    @RequestMapping("/draw-prize")
    public CommonResult<Boolean> drawPrize(@Validated @RequestBody DrawPrizeReq param) {
        logger.info("抽奖 -> DrawPrizeReq: {}", param);
        drawPrizeService.drawPrize(param);
        return CommonResult.success(true);
    }

    @RequestMapping("/winning-records/show")
    public CommonResult<List<WinningRecordResp>> getWinningRecords(@Validated @RequestBody WinningRecordReq param) {
        logger.info("查询活动中奖记录 -> WinningRecordReq: {}", param);
        return CommonResult.success(drawPrizeService.getWinningRecords(param));
    }
}
